package com.andyage.admin.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.andyage.admin.bean.AdorderBean;
import com.andyage.admin.dao.AdOrderMapper;
import com.andyage.admin.service.IAdorderCountService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service
public class AdorderCountServiceImpl implements IAdorderCountService {
	@Resource
	private AdOrderMapper adorderMapper;
	@Override
	public String queryAllOrderPriceSumByDateTime(AdorderBean order) throws Exception {
		double wxIncome = adorderMapper.queryWxOrderPriceSumByDateTime(order);
		double alipayIncome = adorderMapper.queryAliOrderPriceSumByDateTime(order);
		double total = adorderMapper.queryAllOrderPriceSumByDateTime(order);
		JSONObject jsonObject = new JSONObject();
		JSONArray array = new JSONArray();
		if(wxIncome+alipayIncome==total){
			JSONObject json = new JSONObject();
			json.accumulate("wxIncome", wxIncome);
			json.accumulate("alipayIncome", alipayIncome);
			json.accumulate("total", total);
			array.add(json);
			jsonObject.accumulate("rows", array);
		}
		return jsonObject.toString();
	}

}
